package testGuava.example.testGuava;

import org.apache.commons.lang3.time.DateUtils;
import org.junit.Test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @ClassName : org.example.testGuava.DateUtil
 * @Description : 类描述
 * Created by cyd on 2021-09-28 11:16:53
 */
public class DateUtil {

    @Test
    public void test() throws ParseException {
        String time01 = "03:00";
        Date date = DateUtils.parseDate(time01, "hh:mm");
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        System.out.println(calendar.get(Calendar.HOUR_OF_DAY));
        System.out.println(date);
        System.out.println(date.getTime());

        String time02 = "04:00";
        Date date02 = DateUtils.parseDate(time02, "hh:mm");
        System.out.println(date02.getTime());
        System.out.println(date.getTime() < date02.getTime());
    }

    @Test
    public void test02() {
        Date nowTime = new Date();
        SimpleDateFormat format = new SimpleDateFormat("hh:mm");
        String nowTimeStr = format.format(nowTime);
        System.out.println(nowTimeStr);
    }
}
